<?php
  include '../include/functions.php';
  //set session save path
  session_save_path($session_path);
  // Initialize a session. 
  session_start(  );
            //session_destroy();             
  $count++;                         
  $sessionId = session_id();
?>
<!DOCTYPE html PUBLIC "-//W3C//Dtd html 4.01 Transitional//EN""http://www.w3.org/tr/html4/loose.dtd"><html>  <head>	<title>JoshHughes.com Hockey Pool Suggestions</title>	<link rel="stylesheet" href="http://hockey.joshhughes.com/css/hockey.css" type="text/css">
	<style>
	<!--
	label,input, textarea {
		display: block;
		width: 150px;
		float: left;
		margin-bottom: 5px;
		margin-left: 5px;
	}
	
	label {
		text-align: left;
		width: 180px;
	}
	
	br {
		clear: left;
	}
	h2 {
		margin-left: 5px;
		text-align: center;
	}
	-->
	</style>
	<script language="Javascript">
		function redirect () { setTimeout("go_now()",10000); }
		function go_now ()   { window.location.href = "<?= $PHP_SELF; ?>"; }
	</script>  </head>
<?
if ($Submit)
{
    $MailTo = "Hockey Admin <hockey@joshhughes.com>";
    $MailFrom = "From: hockey@joshhughes.com";
    $MailSubject = "Hockey Pool Suggestions";//"NEWS from $dfilename";
    $MailBody = "$SuggesterName <$SuggesterEmail> made the following suggestion:\n\n$Suggestion";
    //Send an Email to me notifying me of a request
    @mail($MailTo, $MailSubject, $MailBody, $MailFrom) or die("couldn't send mail");  //message send
	?>
	<body onLoad="redirect()">
	<H2>Thank you <span style="color: #ff9709;"><?= $SuggesterName; ?></span> for you suggestion.</H2>
	<label>This page will automatically redirect in 10 seconds.</label>
	<?
}
else
{
    if ($userID)
    {
		//Connect To Database
		dbConnect();
		$SQL = "SELECT Username, Email FROM Users WHERE ID = $userID";
		$result = @mysql_query($SQL) or captureCritalFail("MySQL Query Error in suggestions.php, line 42", mysql_error(), $userID, time(), $SQL);
		if($myrow = mysql_fetch_array($result))
		{
			$FromName = $myrow["Username"];
			$FromEmail = $myrow["Email"];
		}
	}
	?><body>
	<form action="<?= $PHP_SELF; ?>" method="POST">

		<label for="SuggesterName">Your Name:</label>
		<?
		if ($FromName)
			echo "<input value=\"$FromName\" disabled><input name=\"SuggesterName\" type=\"hidden\" value=\"$FromName\"><br>";
		else
			echo "<input name=\"SuggesterName\" type=\"text\" value=\"\"><br>";
		?>
	
		<label for="SuggesterEmail">Your Email:</label>
		<?
		if ($FromEmail)
			echo "<input value=\"$FromEmail\" disabled><input name=\"SuggesterEmail\" type=\"hidden\" value=\"$FromEmail\"><br>";
		else
			echo "<input name=\"SuggesterEmail\" type=\"text\" value=\"\"><br>";
		?>
	
		<label for="Suggestion">Your Suggestion:</label>
		<textarea cols="17" rows="5" name="Suggestion"></textarea><br>
		
		<input type="Submit" name="Submit" value="Submit" style="width: 80px;"> <input type="reset" value="Reset!" style="width: 80px;">
	</form>

	<?
}//end if($Submit)
?>
</BODY>
</HTML>